import { Body, Controller, Get, UseGuards, Req, Post } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { OssService } from './oss.service';
import { ApiParam, ApiTags } from '@nestjs/swagger';

@ApiTags('oss')
@Controller('oss')
export class OssController {
    constructor(private readonly ossService: OssService) { }

    @Post('/presign/add')
    @UseGuards(AuthGuard('jwt'))
    presignedUrl(@Req() req, @Body() post_json) {
        return this.ossService.presignedUrl(post_json.bucket ? post_json.bucket : null, req.user.userId)
    }

    @Post('/presign/get')
    @UseGuards(AuthGuard('jwt'))
    presignedGetUrl(@Body() get_json) {
        return this.ossService.presignedGetUrl(get_json.bucket, get_json.file_id)
    }

    @Post('/info')
    @UseGuards(AuthGuard('jwt'))
    statInfo(@Body() get_json) {
        return this.ossService.presignedGetUrl(get_json.bucket, get_json.file_id)
    }

}
